<?php
Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
Yii::setAlias('@school', dirname(dirname(__DIR__)) . '/school');
Yii::setAlias('@task', dirname(dirname(__DIR__)) . '/task');
Yii::setAlias('@workflow', dirname(dirname(__DIR__)) . '/workflow');

function halt($data)
{
    $tranceInfo = debug_backtrace();
    echo '<hr>' . $tranceInfo[0]['file'] . ':' . $tranceInfo[0]['line'] . '<br>';
    echo '<pre>' . var_export($data, 1) . '</pre>';
    die;
}

function dump($data)
{
    $tranceInfo = debug_backtrace();
    echo '<hr>' . $tranceInfo[0]['file'] . ':' . $tranceInfo[0]['line'] . '<br>';
    echo '<pre>' . var_export($data, 1) . '</pre>';
}

function dumpTable(array $data) {
    $table = '<table border="1">';
    if ($data) {
        $firstRow = current($data);
        $title = array_keys($firstRow);
        array_unshift($title, '');
        $table .= '<thead><tr>';

        foreach ($title as $th) {
            $table .= "<th>{$th}</th>";
        }
        $table .= '</tr></thead><tbody>';

        $i = 1;
        foreach ($data as $row) {
            $table .= "<tr>";
            $table .= "<th>{$i}</th>";
            foreach ($row as $col) {
                $table .= "<th>{$col}</th>";
            }
            $table .= "</tr>";
            $i++;
        }
        $table .= '</tbody>';
    } else {
        $table .= '<tr><td>N/A</td></tr>';
    }
    $table .= '</table>';

    echo $table;
}